using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using API;
using mb;
using Mb;
using Xamarin.Forms;

namespace libhot
{
	public static partial class Entry
	{
		static async partial void _OnLoad()
		{
			// return;
			HasOnLoad = true;
			App.Instance.MainPage = new NavigationPage(new HotEntryPage());

			return;
			CatLib.App.Unbind("API.IPopManager"); CatLib.App.Singleton<IPopManager, MyPopManager>();
		}
	}

	public class HotEntryPage : TabbedPage
	{
		static IStartOption startOption = CatLib.App.Make<IStartOption>();
		static public HotEntryPage Instance;

		public HotEntryPage()
		{
			Instance = this;
			this.EnableNavBar(false);

			App.logger.Log("HotEntryPage...");
			var hrm = CatLib.App.Make<HotReloadManager>();
			hrm.RegisterReload(this, "tab", (resName) =>
			{
				App.logger.Log("tabpage reload");
				this.Children.Clear();
				this.LoadXamlFromRes(resName);
				// this.DoLoad();

			});

			CatLib.App.Make<IGlobal>().LockDeviceOrientation(DeviceOrientation.UP);
		}

		protected override void OnAppearing()
		{
			base.OnAppearing();
		}

		protected override bool OnBackButtonPressed()
		{
			App.logger.Log("backpress!!!!");
			mb.Util.ExitApp();
			return true;
		}

		protected void DoLoad()
		{
			App.logger.Log("tabpage doload");
			// if (!this.LoadXamlFromRes(FormResName))
			// return;

			// this.FindByName<View>("tip").GestureRecognizers.Add(
			// 	new TapGestureRecognizer()
			// 	{
			// 		Command = new Command(() =>
			// 		{
			// 			System.Console.WriteLine("click");
			// 		})
			// 	}
			// );
		}

		void OnTapped(object sender, EventArgs e)
		{
			App.logger.Log("---click!!!!,{0},{1}", sender, e);
		}
		void OnTestTapped(object sender, EventArgs e)
		{
			App.logger.Log("test,{0},{1}", sender, e);
		}


	}
}